package com.wavehi.exce.method_reference;

import com.wavehi.exce.functional_interface.MyInterface1;
import com.wavehi.pojo.Person;
import org.junit.Test;

import java.util.function.Supplier;

/**
 * @Author WaveHi
 * @Date 27/8/2021 上午 9:30
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description Demonstrate the use of method reference.
 */
public class MethodReferenceDemo1 {

    @Test
    public void testMethodReference1() {
        //获取实例
        MyInterface1 mi1 = System.out::print;
        //测试
        mi1.print("Wow!");
    }

    @Test
    public void testMethodReference2() {
        //获取
        Supplier<Person> supplier = Person::new;
        //获取对象
        Person person = supplier.get();
        //测试
        person.setName("Ton");
        person.setAge(21);
        //
        System.out.println(person);
    }

}
